Option Explicit On
Option Strict On

Imports TreeCreeper01Interfaces


Friend Class cSpatialPlantMapLocation
    Implements ISpatialPlantMapLocation

    Private pIndex As Integer
    Private pXCoordinate As Double
    Private pYCoordinate As Double


    Public Sub New(ByVal Index As Integer, ByVal xCoordinate As Double, ByVal yCoordinate As Double)
        pIndex = Index
        pXCoordinate = xCoordinate
        pYCoordinate = yCoordinate
    End Sub


    Public ReadOnly Property Index() As Integer Implements TreeCreeper01Interfaces.ISpatialPlantMapLocation.Index
        Get
            Return pIndex
        End Get
    End Property

    Public ReadOnly Property xCoordinate() As Double Implements TreeCreeper01Interfaces.ISpatialPlantMapLocation.xCoordinate
        Get
            Return pXCoordinate
        End Get
    End Property

    Public ReadOnly Property yCoordinate() As Double Implements TreeCreeper01Interfaces.ISpatialPlantMapLocation.yCoordinate
        Get
            Return pYCoordinate
        End Get
    End Property

    Public Function GetDistanceFrom(ByVal AnotherLocation As TreeCreeper01Interfaces.ISpatialPlantMapLocation) As Double Implements TreeCreeper01Interfaces.ISpatialPlantMapLocation.GetDistanceFrom

        Dim Dist As Double

        Dist = (pXCoordinate - AnotherLocation.xCoordinate) ^ 2
        Dist = Dist + (pYCoordinate - AnotherLocation.yCoordinate) ^ 2
        Dist = Dist ^ 0.5

        Return Dist

    End Function

End Class